package com.jinxi.web.rest;

import com.jfinal.plugin.activerecord.Page;
import com.jinxi.web.entitiy.Area;
import com.jinxi.web.service.AreaService;
import com.jinxi.web.util.ResultMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by changqi.wu on 2017/10/30.
 */

@RequestMapping("/test")
@Controller
public class AreaController {

    @Autowired
    private AreaService areaService;

    @RequestMapping("list.json")
    @ResponseBody
    public ResultMessage list(Integer page, Integer pageSize, HttpServletRequest request) {
        if (page == null) {
            page = 1;
        }
        if (pageSize == null) {
            pageSize = 30;
        }

        Page<Area> datas = areaService.getAreaList(page, pageSize);

        return new ResultMessage(ResultMessage.Result.OK, datas);
    }

}
